1. Field of the Invention
The invention relates in general to a method and an apparatus for image decoding, and in particular to a method and apparatus for decoding progressively encoded image.
2. Description of the Related Art
JPEG is a standard for gray or color still image compression, and is widely used due to its effectiveness. JPEG provides four different modes with respective encoding and decoding methods. The four modes are sequential discrete cosine transform (DCT) based mode, progressive DCT-based mode, lossless mode, and hierarchical mode, where DCT is used for transforming signals in the time domain into signals in the frequency domain.
For the sequential DCT-based mode, uncompressed samples of an image are grouped into sample blocks of 8 by 8 pixels, and the sample blocks are processed block by block from left to right and block-row by block-row from top to bottom. When one of the sample blocks is transformed into 64 DCT coefficients by forward DCT, the 64 DCT coefficients are quantized by a quantizer and then the JPEG bit stream is produced by performing variable length encoding, for example, Huffman encoding, of the quantized DCT coefficients by a variable length encoder.
For the progressive DCT-based mode, the sample blocks of an image are also typically encoded in the same order as the sequential DCT-based mode, but in multiple scans through the image. After compression, the JPEG bit stream then includes multiple progressively encoded scan data. The encoding process is accomplished by adding an image-sized coefficient memory buffer between the quantizer and the variable length encoder. This buffer stores the coefficients of the whole image. As each sample block is transformed by performing forward DCT and then quantized, its quantized DCT coefficients are obtained and temporarily stored in this buffer. After all the sample blocks are transformed and quantized, the quantized DCT coefficients are stored in the buffer and then partially encoded in multiple scans. For each scan, the variable length encoder partially encodes the quantized DCT coefficients. The progressive DCT-based mode advantages the progressive decoding of the image when the image data is being transmitted in a limited network bandwidth environment. In such case, the decoder at the receiving end can decode the arrived scan data from the JPEG bit stream, so a rough image can be displayed at the receiving end. The image is further refined progressively when more subsequent scans are received at the receiving end. In this way, the decoding of the bit stream at the receiving end can begin without waiting for the entire bit stream to arrive, and the received image data is updated progressively.
There are two methods by which the quantized DCT coefficients in the buffer may be partially encoded within a scan. They are spectral selection and successive approximation methods. In the spectral selection method, only a specified frequency band of the coefficients of each sample block needs to be encoded in each scan. For example, the lower-frequency image data of the sample block is encoded first, and then the higher-frequency image data of the sample block is encoded. In the successive approximation method, a portion of bits of each quantized DCT coefficient is encoded each time. A specified number of most significant bits (MSB) are first encoded. In subsequent scans, a specified number of least significant bits (LSB) are encoded.
FIG. 1 illustrates the spectral selection method. In FIG. 1, each small cube represents one bit and each row of cubes represents a quantized DCT coefficient of a sample block, where the bit on the leftmost side and the bit on the rightmost side of each row are the MSB and the LSB of the corresponding quantized DCT coefficient, respectively. The 64 successive rows of cubes from top to bottom represent all 64 DCT coefficients of a sample block. In the first scan, the zeroth quantized DCT coefficients of all sample blocks, referred to as scan 0, are encoded. In the second scan, the first and second quantized DCT coefficients of all sample blocks, referred to as scan 1, are encoded. In the third scan, the third, fourth, and fifth quantized DCT coefficients of all sample blocks, referred to as scan 2, are encoded. In the subsequent scans, the remaining scans are encoded in this way. Since each quantized DCT coefficient of a sample block corresponds to a different frequency band, spectral selection method is achieved by encoding different quantized DCT coefficients of the sample blocks according to their frequency band.
FIG. 2 illustrates the successive approximation method. In the first scan, the zeroth quantized DCT coefficients of all sample blocks are encoded and referred to as scan 0. In the second scan, the fourth, fifth, sixth, and seventh bits of the quantized DCT coefficients of all sample blocks are encoded and referred to as scan 1. In the third scan, the third bits of the quantized DCT coefficients of all sample blocks are encoded and referred to as scan 2. In this way, successive approximation is achieved by encoding the corresponding bits for all sample blocks according to their significance. In addition, a different progressive sequence can be achieved by combining the spectral selection method with the successive approximation method.
After illustrating progressive JPEG encoding methods, the progressive JPEG decoding method is now discussed. In a typical progressive JPEG decoding system, an image-sized coefficient memory buffer is required to store the variable-length-decoded coefficients after variable length decoding. When collecting all the variable-length-decoded coefficients of a scan, the decoder may further perform inverse quantization and inverse DCT (IDCT) operations upon these variable-length-decoded coefficients to produce a partially reconstructed image, whereby the partially reconstructed image can first be displayed. The partially reconstructed image can later be refined progressively when the variable-length-decoded coefficients of other scans are also ready and processed by the IDCT operations. However, the main drawback of the typical progressive JPEG decoding system is the requirement of an image-sized coefficient memory buffer. Since the image to be reconstructed may have a huge size, the buffer size will become very large. For example, an image may have a maximum size of 65,535 by 65,535 pixels as specified in JPEG T.81 specification. Since an ordinary JPEG decoding system does not have such a large buffer, the decoding of the image would fail. Furthermore, information appliance (IA) products are widely used nowadays, and are generally equipped with a much smaller memory. For these IA products, decoding of a large-sized progressive JPEG compressed image becomes impossible. Hence, in view of the above-mentioned problems, it is desirable to develop a progressive JPEG decoding apparatus and method, which can decode progressive JPEG compressed images even under an environment with limited memory resources.